<?php
/**
 * Created by PhpStorm.
 * Created at 21/05/2018 10:54.
 */

require_once __DIR__ . '/../vendor/autoload.php';

$container = new \Illuminate\Container\Container();

// 有两个类需要用到同一个接口，同时也需要为每个类注入不同的接口实现
// 例如，GoodBar 需要依赖 GoodFoo
// BadBar 需要依赖 BadFoo
$container->when(\App\Bar\GoodBar::class)
    ->needs(\App\Contracts\FooInterface::class)
    ->give(\App\Foo\GoodFoo::class);

$container->when(\App\Bar\BadBar::class)
    ->needs(\App\Contracts\FooInterface::class)
    ->give(\App\Foo\BadFoo::class);

dump($container);

dump($container->make(\App\Bar\GoodBar::class));
dump($container->make(\App\Bar\BadBar::class));
